package cl.rizepe.playntest.core.menu;

import pythagoras.f.Point;

public class MenuDirectionClock extends MenuDirection9 {
	float angle;
	final float minR ;

	public MenuDirectionClock(Point origin, Point buttonSize, int direction) {
		this(origin, buttonSize, direction,
				(float) Math.sqrt(buttonSize.x()*buttonSize.x()
						+buttonSize.y()*buttonSize.y()));
		
	}
	
	public MenuDirectionClock(Point origin, Point buttonSize, int direction, int rUnits) {
		this(origin, buttonSize, direction,
				rUnits*(float) Math.sqrt(buttonSize.x()*buttonSize.x()
						+buttonSize.y()*buttonSize.y())/2);
		
	}
	
	public MenuDirectionClock(Point origin, Point buttonSize, int direction,float minR) {
		super(origin, buttonSize, direction);
		this.minR=Math.abs(minR);
	}
	
	@Override
	public Point pointLocation(int index) {
		float buttonR=(float) Math.sqrt(buttonSize.x()*buttonSize.x()+buttonSize.y()*buttonSize.y());
		float angleStep=(float) (Math.PI*2/Math.pow(2,2+ (minR/buttonR)));
		float angle= (float) ((index*angleStep)%(Math.PI*2));
	//	float sin =(float) (angle*(Math.PI*2));
		float x= (float) (Math.cos(angle)*minR) ;//-minR/2;
		float y =(float) (Math.sin(angle)*minR) ;//-minR/2;
		/*
		if (angle>Math.PI)
			x*=-1;
		if (angle>Math.PI)
			y*=-1;/**/
		return new Point(x,y);
	}
	
	
}

